import {
  q as s,
  p as q,
  ap as G,
  X as w,
  f as X,
  H as $,
  av as B,
  aw as K,
  k as t,
  m as a,
  l,
  ax as F,
  az as Q,
  as as d,
  aG as Z,
  at as D
} from "./index-b50e6ef9.js";
import { i as C } from "./vip-d2446e08.js";
function ae(E) {
  const h = s([]),
    i = s(!0);
  s({}), q();
  const x = s(1),
    m = s(""),
    g = s(""),
    v = s(10),
    r = s([]),
    y = s(""),
    S = G("reload"),
    b = w({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    Y = w({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    I = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "用户ID", prop: "user_id", minWidth: 50 },
      { label: "用户名", prop: "user_name", minWidth: 80 },
      { label: "手机号", prop: "user_phone", minWidth: 100 },
      {
        label: "档位",
        prop: "user_position",
        minWidth: 100,
        formatter: ({ user_position: e }) =>
          e == 1
            ? t(
                l("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [a("1799档位")] }
              )
            : e == 2
            ? t(
                l("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [a("5000档位")] }
              )
            : t(
                l("el-tag"),
                { class: "mx-1", type: "info", effect: "light" },
                { default: () => [a("暂无")] }
              )
      },
      {
        label: "商品名称",
        prop: "wares",
        minWidth: 250,
        formatter: ({ wares: e, activity: n }) =>
          t("div", null, [
            t("div", null, [e]),
            n == 1
              ? t(
                  l("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [a("已赠送")] }
                )
              : ""
          ])
      },
      { label: "商品价格", prop: "wares_price", minWidth: 100 },
      { label: "内含数量", prop: "all_bottle", minWidth: 100 },
      { label: "单位", prop: "wares_unit", minWidth: 100 },
      { label: "支付金额", prop: "pay_price", minWidth: 100 },
      {
        label: "状态",
        prop: "status",
        minWidth: 150,
        formatter: ({ status: e, track_name: n, content: o }) => {
          if (e == 1)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "", effect: "light" },
              { default: () => [a("待发货")] }
            );
          if (e == 2)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "", effect: "light" },
              { default: () => [a("待自提")] }
            );
          if (e == 7)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("在线支付积分不足")] }
            );
          if (e == 8)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("奖励发放中")] }
            );
          if (e == 9)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("待发放奖励")] }
            );
          if (e == 3 && n != "自提")
            return t("div", null, [
              " ",
              t(
                l("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [a("已快递")] }
              )
            ]);
          if (e == 3 && n == "自提")
            return t("div", null, [
              " ",
              t(
                l("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [a("已自提")] }
              )
            ]);
        }
      },
      {
        label: "创建时间",
        minWidth: 180,
        prop: "add_time",
        formatter: ({ add_time: e }) => F(e * 1e3).format("YYYY-MM-DD HH:mm:ss")
      }
    ],
    M = X(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]),
    z = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "user_id", minWidth: 100 },
      { label: "用户名", prop: "user_name", minWidth: 80 },
      { label: "手机号", prop: "user_phone", minWidth: 100 },
      { label: "档位", prop: "user_position", minWidth: 100 },
      { label: "商品名称", prop: "wares", minWidth: 100 },
      { label: "商品价格", prop: "wares_price", minWidth: 100 },
      { label: "商品数量", prop: "wares_num", minWidth: 100 },
      { label: "内含数量", prop: "all_bottle", minWidth: 100 },
      { label: "单位", prop: "wares_unit", minWidth: 100 },
      { label: "门店码", prop: "store_code", minWidth: 100 },
      { label: "支付金额", prop: "pay_price", minWidth: 100 },
      {
        label: "创建时间",
        minWidth: 180,
        prop: "add_time",
        formatter: ({ add_time: e }) => F(e * 1e3).format("YYYY-MM-DD HH:mm:ss")
      },
      { label: "", minWidth: 180, prop: "0" }
    ];
  async function J(e) {
    Q(e);
  }
  async function H(e) {
    const n = { role_id: e.role_id },
      o = JSON.stringify(n),
      f = { value: d.enc.Base64.stringify(d.enc.Utf8.parse(o)) },
      u = await Z(f);
    u.code == 200
      ? (D("删除成功", { type: "success" }), S())
      : D(u.msg, { type: "error" });
  }
  function N() {}
  function U(e) {
    (v.value = e), W(void 0, e);
  }
  function k(e) {
    (x.value = e), W(e, void 0);
  }
  function A(e) {}
  function L(e) {
    (Y.text = `正在加载第${e}页...`),
      (i.value = !0),
      B(600).then(() => {
        i.value = !1;
      });
  }
  async function T(e, n = [], o, c) {
    (r.value = []),
      (i.value = !0),
      (y.value = e.user_phone),
      n.map(R => {
        const j = R,
          P = new Date(j);
        r.value.push(
          P.toLocaleDateString("zh-CN", {
            year: "numeric",
            month: "2-digit",
            day: "2-digit"
          })
        );
      });
    const f = {
        page: 1,
        pagesize: v.value,
        user_phone: e.user_phone ? e.user_phone : void 0,
        start: r.value[0],
        end: r.value[1],
        action: o || void 0,
        indent: c || void 0
      },
      u = JSON.stringify(f),
      O = { value: d.enc.Base64.stringify(d.enc.Utf8.parse(u)) },
      { data: _ } = await C(O);
    (h.value = _.data),
      (b.total = _.total),
      setTimeout(() => {
        i.value = !1;
      }, 500);
  }
  async function W(e = x.value, n = v.value) {
    const o = {
        page: e,
        pagesize: n,
        user_phone: y.value ? y.value : void 0,
        start: r.value[0],
        end: r.value[1],
        action: m.value ? m.value : void 0,
        indent: g.value ? g.value : void 0
      },
      c = JSON.stringify(o),
      u = { value: d.enc.Base64.stringify(d.enc.Utf8.parse(c)) },
      p = await C(u);
    p.code === 200
      ? ((h.value = p.data.data),
        (b.total = p.data.total),
        setTimeout(() => {
          i.value = !1;
        }, 500))
      : D(p.msg, { type: "error" });
  }
  const V = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    $(() => {
      B().then(() => {
        const { setWatermark: e } = K(E.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        (i.value = !1);
    }),
    {
      loading: i,
      columns: I,
      dataList: h,
      pagination: b,
      buttonClass: M,
      formattedDate: r,
      columnsTable: z,
      onSearch: T,
      gradeVip: m,
      gradeVip1: g,
      resetForm: V,
      handleaddUser: N,
      handleUpdate: J,
      handleDelete: H,
      handleSizeChange: U,
      handleCurrentChange: k,
      handleSelectionChange: A,
      onCurrentChange: L
    }
  );
}
export { ae as useRole };
